import request from '@/utils/request'

// 获取SPU列表
export const reqSpuList = (page, limit, category3Id) => request({ url: `/dev-list/admin/product/${page}/${limit}`, method: "get", params: { category3Id } })

//获取SPU信息
export const reqSpu = (id) => request.get(`/dev-list/admin/product/getSpuById/${id}`)

//获取品牌信息
export const reqTradeMarkList = () => request.get(`/dev-list/admin/product/baseTrademark/getTrademarkList`)

//获取图片
export const reqSpuImageList = (id) => request.get(`/dev-list/admin/product/spuImageList/${id}`)

//获取销售属性
export const reqBaseSaleAttrList = () => request.get(`/dev-list/admin/product/baseSaleAttrList`)

// 保存或修改 如果info中有ID就是修改，没有就是保存
export const reqSaveOrUpdateSpu = (spuInfo) => {
    if (spuInfo.id) {
        return request.post(`/dev-list/admin/product/updateSpuInfo`, spuInfo)
    } else {
        return request.post(`/dev-list/admin/product/saveSpuInfo`, spuInfo)
    }
}

// 删除SPU
export const reqDeleteSpu = (id) => request.delete(`/dev-list/admin/product/deleteSpu/${id}`)

// 获取销售属性
export const reqSpuSaleAttrList = (id) => request.get(`/dev-list//admin/product/spuSaleAttrList/${id}`)

// 获取attrInfoList
export const reqAttrInfoList = (levelOneId, levelTwoId, levelThreeId) => request.get(`/dev-list/admin/product/attrInfoList/${levelOneId}/${levelTwoId}/${levelThreeId}`)

// 保存SKU
export const reqSaveSku = (data) => request.post(`/dev-list/admin/product/saveSkuInfo`, data)
// export const reqSaveSku = (data) => request({ url: `/dev-list/admin/product/saveSkuInfo`, method: "POST", data: data })

// 获取sku列表数据
export const reqSkuList = (id) => request.get(`/dev-list/admin/product/findBySpuId/${id}`)